package com.turbo.action;

import com.intellij.ide.IdeView;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.psi.PsiFile;
import com.turbo.dialog.ReadDialog;
import org.jetbrains.annotations.NotNull;

/**
 * @author: zwx
 * @time: 2021/3/22 20:06
 */
public class ReadAction extends AnAction {
    @Override
    public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
        ReadDialog readDialog = new ReadDialog(anActionEvent);
        readDialog.pack();
        readDialog.show();
    }

    @Override
    public void update(@NotNull AnActionEvent anActionEvent) {
        PsiFile psiFile = anActionEvent.getData(PlatformDataKeys.PSI_FILE);
        anActionEvent.getPresentation().setEnabled(psiFile == null);
//        PsiFile psiFile = anActionEvent.getData(PlatformDataKeys.PSI_FILE);
//        String name = Optional.ofNullable(psiFile).map(PsiFile::getName).orElse(StringUtils.EMPTY);
//        anActionEvent.getPresentation().setEnabled(StringUtils.isNotBlank(name) && "fc.yml".equals(name));
    }
}
